package ma.ac.onousc.gestionfi.EngagementPaiement.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import ma.ac.onousc.gestionfi.budget.model.RubriqueBudgetaire;


@Entity
@NamedQuery(name = "Engagement.findByRB", query = "select eng from Engagement eng where eng.rubriqueBudgetaire=:rb")
@DiscriminatorColumn(name = "eng_type")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Engagement implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int idEngagement;
	private String numEngagement;
	private String typeEngagement;
	private String fichierJoint;

	@Temporal(TemporalType.TIMESTAMP)
	private Date dateEngagement;

	private double montantEngagement;

	// bi-directional many-to-one association to Paiement
	@OneToMany(mappedBy = "engagement",fetch = FetchType.EAGER)
	private List<OrdrePaiement> ordrePaiement;

	// bi-directional many-to-one association to RubriqueBudgetaire
	@ManyToOne(fetch = FetchType.EAGER)
	private RubriqueBudgetaire rubriqueBudgetaire;

	@ManyToOne(fetch = FetchType.EAGER)
	private Prestation prestation;

	public Engagement() {
	}
	
	

	public Engagement(String numEngagement, Date dateEngagement,
			double montantEngagement, String typeEngagement) {
		super();
		this.numEngagement = numEngagement;
		this.dateEngagement = dateEngagement;
		this.montantEngagement = montantEngagement;
	}



	public int getIdEngagement() {
		return idEngagement;
	}

	public void setIdEngagement(int idEngagement) {
		this.idEngagement = idEngagement;
	}

	public Date getDateEngagement() {
		return dateEngagement;
	}

	public void setDateEngagement(Date dateEngagement) {
		this.dateEngagement = dateEngagement;
	}

	public double getMontantEngagement() {
		return montantEngagement;
	}

	public void setMontantEngagement(double montantEngagement) {
		this.montantEngagement = montantEngagement;
	}


	public String getNumEngagement() {
		return numEngagement;
	}

	public void setNumEngagement(String numEngagement) {
		this.numEngagement = numEngagement;
	}

	public List<OrdrePaiement> getOrdrePaiement() {
		return ordrePaiement;
	}

	public void setOrdrePaiement(List<OrdrePaiement> ordrePaiement) {
		this.ordrePaiement = ordrePaiement;
	}

	public RubriqueBudgetaire getRubriqueBudgetaire() {
		return rubriqueBudgetaire;
	}

	public void setRubriqueBudgetaire(RubriqueBudgetaire rubriqueBudgetaire) {
		this.rubriqueBudgetaire = rubriqueBudgetaire;
	}

	public Prestation getPrestation() {
		return prestation;
	}

	public void setPrestation(Prestation prestation) {
		this.prestation = prestation;
	}



	public String getTypeEngagement() {
		return typeEngagement;
	}



	public void setTypeEngagement(String typeEngagement) {
		this.typeEngagement = typeEngagement;
	}



	public String getFichierJoint() {
		return fichierJoint;
	}



	public void setFichierJoint(String fichierJoint) {
		this.fichierJoint = fichierJoint;
	}
	
	

}